The present invention generally relates to graphics processing and, more particularly, to a method and apparatus for determining the centroid of an image fragment to be sampled.
In computer graphics applications, complex shapes and structures are formed through the sampling, interconnection and rendering of more simple shapes, referred to as primitives. An example of such a primitive is a triangle. Physical attributes such as color, shading and texture are often applied to the rendered primitives to make them look more realistic.
Primitives and the attributes they possess are defined in part by the vertices thereof. Known techniques for applying attributes to a primitive include interpolating the attributes from the vertices of the primitive. Such interpolation is accomplished by sampling the plurality of pixels that comprise the primitive at their corresponding center points. The sampling is generally performed in a graphics processor by a raster engine or suitable circuitry.
The raster engine uses barycentric coordinates of the vertices of the primitives to interpolate attribute values for the individually sampled pixels. The barycentric coordinates are comprised of a weight that is applied to the respective vertex coordinates of the primitive. Each weight at a barycentric coordinate within the triangle has a value between zero and one, inclusive and the sum of the weights at each position is always one. After the raster engine has sampled the pixels, and the physical attributes applied thereto, the sampled primitive is then transferred to an image buffer. The contents of the image buffer are later displayed on a suitable display device.
A drawback associated with conventional sampling methods, occurs when using a multisampling algorithm to render an anti-aliased image. Multisampling algorithms compute attribute values at more than one position within each pixel. As a result, the center of the pixel being sampled can be located outside of the primitive present therein. In other words, the primitive to be rendered may not cover the center of the pixel. Subsequently, if the pixel is sampled without including the entirety of the fragment contained therein, artifacts may be generated in the sampled pixel. This results in the rendered image containing wrongfully colored spots at various points thereof. Consequently, sampling at the center of a pixel when the primitive lies outside the center of the pixel results in degraded rendered image quality.
Thus, there is a need for an improved sampling method and apparatus which provides for the center point of the fragment of a primitive to be rendered always being sampled notwithstanding the location within a pixel.